package org.sdp.pearproject.controller;


import org.sdp.pearproject.controller.custom.*;
import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: ProjectMemberController
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-12
 * @Version: 1.0
 * Table: pear_project_member
 * Comment:
 * 项目-成员表
 */
@RestController
@RequestMapping(value = "/project_member")
public class ProjectMemberController extends ProjectMemberCustomController {
    static {
        addRequestClass("project_member", "add", "projectMemberController", ProjectMemberController.class, ProjectMemberAddRequest.class);
        addRequestClass("project_member", "add_encrypt", "projectMemberController", ProjectMemberController.class, ProjectMemberAddRequest.class);

        addRequestClass("project_member", "update", "projectMemberController", ProjectMemberController.class, ProjectMemberUpdateRequest.class);
        addRequestClass("project_member", "update_encrypt", "projectMemberController", ProjectMemberController.class, ProjectMemberUpdateRequest.class);

        addRequestClass("project_member", "delete", "projectMemberController", ProjectMemberController.class, ProjectMemberDeleteRequest.class);
        addRequestClass("project_member", "delete_encrypt", "projectMemberController", ProjectMemberController.class, ProjectMemberDeleteRequest.class);

        addRequestClass("project_member", "query", "projectMemberController", ProjectMemberController.class, ProjectMemberQueryRequest.class);
        addRequestClass("project_member", "query_encrypt", "projectMemberController", ProjectMemberController.class, ProjectMemberQueryRequest.class);

        addRequestClass("project_member", "list", "projectMemberController", ProjectMemberController.class, ProjectMemberQueryRequest.class);
        addRequestClass("project_member", "list_encrypt", "projectMemberController", ProjectMemberController.class, ProjectMemberQueryRequest.class);

        addRequestClass("project_member", "count", "projectMemberController", ProjectMemberController.class, ProjectMemberQueryRequest.class);
        addRequestClass("project_member", "count_encrypt", "projectMemberController", ProjectMemberController.class, ProjectMemberQueryRequest.class);

        addRequestClass("project_member", "stat", "projectMemberController", ProjectMemberController.class, ProjectMemberQueryRequest.class);
        addRequestClass("project_member", "stat_encrypt", "projectMemberController", ProjectMemberController.class, ProjectMemberQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addProjectMember(@MixRequestBody ProjectMemberAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_member", "add", request, callFromEncrypt);
        return super.addProjectMember(request);
    }

    @PostMapping("/add_encrypt")
    public String addProjectMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectMemberAddRequest request = (ProjectMemberAddRequest) super.decrypt("project_member", "add_encrypt", strRequest, ProjectMemberAddRequest.class);
        Integer result = addProjectMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateProjectMember(@MixRequestBody ProjectMemberUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_member", "update", request, callFromEncrypt);
        return super.updateProjectMember(request);
    }

    @PostMapping("/update_encrypt")
    public String updateProjectMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectMemberUpdateRequest request = (ProjectMemberUpdateRequest) super.decrypt("project_member", "update_encrypt", strRequest, ProjectMemberUpdateRequest.class);
        Integer result = updateProjectMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteProjectMember(@MixRequestBody ProjectMemberDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_member", "delete", request, callFromEncrypt);
        return super.deleteProjectMember(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteProjectMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectMemberDeleteRequest request = (ProjectMemberDeleteRequest) super.decrypt("project_member", "delete_encrypt", strRequest, ProjectMemberDeleteRequest.class);
        Integer result = deleteProjectMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public ProjectMemberQueryResponse queryProjectMember(@MixRequestBody ProjectMemberQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("project_member", "query", request, callFromEncrypt);
      return super.queryProjectMember(request);
    }

    @PostMapping("/query_encrypt")
    public String queryProjectMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectMemberQueryRequest request = (ProjectMemberQueryRequest) super.decrypt("project_member", "query_encrypt", strRequest, ProjectMemberQueryRequest.class);
        ProjectMemberQueryResponse result = queryProjectMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<ProjectMemberQueryResponse> listProjectMember(@MixRequestBody ProjectMemberQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_member", "list", request, callFromEncrypt);
        if (super.needTotal("project_member", "list", request)) {
            super.setTotal("project_member", "list", request, super.countProjectMember(request));
        }
        return super.listProjectMember(request);
    }

    @PostMapping("/list_encrypt")
    public String listProjectMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectMemberQueryRequest request = (ProjectMemberQueryRequest) super.decrypt("project_member", "list_encrypt", strRequest, ProjectMemberQueryRequest.class);
        List<ProjectMemberQueryResponse> result = listProjectMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countProjectMember(@MixRequestBody ProjectMemberQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("project_member", "count", request, callFromEncrypt);
      return super.countProjectMember(request);
    }


    @PostMapping("/count_encrypt")
    public String countProjectMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectMemberQueryRequest request = (ProjectMemberQueryRequest) super.decrypt("project_member", "count_encrypt", strRequest, ProjectMemberQueryRequest.class);
        Integer result = countProjectMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statProjectMember(@MixRequestBody ProjectMemberQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_member", "stat", request, callFromEncrypt);
        return super.statProjectMember(request);
    }

    @PostMapping("/stat_encrypt")
    public String statProjectMemberEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectMemberQueryRequest request = (ProjectMemberQueryRequest) super.decrypt("project_member", "stat_encrypt", strRequest, ProjectMemberQueryRequest.class);
        BaseStatResponse result = statProjectMember(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }


}
